package com.softeem.score.manager.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.softeem.score.common.log.service.AsyncOperLogService;
import com.softeem.score.manager.mapper.SysOperLogMapper;
import com.softeem.score.model.dto.SysOperLogDto;
import com.softeem.score.model.entity.system.SysOperLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AsyncOperLogServiceImpl implements AsyncOperLogService {

    @Autowired
    private SysOperLogMapper sysOperLogMapper;

    @Async      // 异步执行保存日志操作
    @Override
    public void saveSysOperLog(SysOperLog sysOperLog) {
        sysOperLogMapper.insert(sysOperLog);
    }

    @Override
    public PageInfo<SysOperLog> findByPage(SysOperLogDto sysOperLogDto, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<SysOperLog> sysOperLogList = sysOperLogMapper.findByPage(sysOperLogDto);
        return new PageInfo<>(sysOperLogList);
    }
}